
const fs =require('fs')

const appRouter = (app) => {
  fs.readdirSync(__dirname).forEach((file) => {
    if (file === "index.ts" || file === "index.js") {
      return;
    } else {
      const route = require(`./${file}`);
      app.use(route.routes()).use(route.allowedMethods()); //allowedMethods 允许使用options方法
    }
  });
};

module.exports = appRouter;
